<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once(APPPATH.'controllers/Abstractfront.php');
class Search extends Abstractfront 
{
	public function __construct() 
	{
        parent::__construct();
        $this->load->model("Searchmodel",'search');
    }

	public function index()
	{
		$data['nav']='add';
		$this->load->view('search',$data);
	}

	
	public function s(){
		$page = $this->input->get("page");
		$value = $this->input->post('value');
		
		if(isset($page)){
			$value = $this->input->get('value');
 		}
 		
		if(!isset($page) || $page <= 0){$page = 1;}		
		$page_size = 20;
		$start = ($page-1)  * $page_size;
		$info = $this->search->item($value,$start,$page_size);
		$num = $this->search->getNum($value);
		$a = intval($num / $page_size);
		$b = $num % $page_size;
		if($b == 0){$page_totle = $a;}else {$page_totle = $a + 1;}
		
		$data['value'] = $value;
		$data['info'] = $info;
		$data['num'] = $num;
		$data['page'] = $page;
		$data['page_totle'] = $page_totle;
		
		$this->load->view('search_result',$data);
	}

}
